﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Web.Security;
using SmartProject.BusinessObjects;

namespace SmartProject.AppSpace
{
    public partial class ChangePassword : UI.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.SetPage("Change my Password", "You will need to enter your old password in order to set a new one.");
            }
        }

        protected void BtnSave_Click(object sender, EventArgs e)
        {
            User user = new User();
            if (!user.ChangePassword(base.UserName, this.TxtOldPassword.Text, this.TxtNewPassword.Text))
            {
                this.DisplayErrorOrWarning("There was a problem setting your new password.");
            }
            else
            {
                Server.Transfer("~/AppSpace/MyPage.aspx");
            }
        }

        public override void RefreshPage(object obj)
        {
            // Do nothing.
        }

        public override AjaxControlToolkit.ModalPopupExtender Popup(string name)
        {
            return null;
        }
    }
}
